<?php include('./public/header.php') ?>
<link href="../css/school-list.css?v=1" rel="stylesheet">

<body>
<div class="my-container">
    <div id="list">
        <!-- <div class="slide">
            <div class="slide-item">
                <div class="wrap">
                    <img src="../img/1.png" alt="" /><p>伟童幼儿园</p>
                </div>
            </div>
        </div> -->
    </div>
</div>

</body>
<?php include('./public/footer.php') ?>
<script>
var datas = {
    urlGetList: parameters.urlSchoolList,
};
var methods = {
    getList: function() {
        $.ajax({
            url: datas.urlGetList,
            type: 'POST',
            data: {
                user_id: getCookie('id'),
                user_name: getCookie('user'),
                role: getCookie('role'),
            },
        })
        .done(function(data) {
            var data = JSON.parse(data);
            setTimeout(function() {
                for (var i in data) {
                    $('#list').append('\
                        <div class="slide">\
                            <div class="slide-item ' + (data[i].priority == 1 ? 'active' : 'not') + '">\
                                <div class="wrap" style="background-image: url(' + parameters.srcImg + data[i].thumb + ')">\
                                    <p>' + data[i].school_name + '</p>\
                                </div>\
                            </div>\
                        </div>\
                    ');
                }
            }, 300);

            console.log("success");
        })
        .fail(function() {
            console.log("error");
        })
        .always(function() {
            console.log("complete");
        });

    }
};
var mounted = function() {
    methods.getList();
    $('#list').on('click', '.slide-item', function() {
        if ($(this).is('.active')) {
            window.location.href = '../output/index.html';
        } else {
            alert('没有该权限');
        }
    });
};

mounted();
</script>
